home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / bchelp10.zip / TI645.ASC < prev    next >
Text File  |  1991-09-18  |  3KB  |  133 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  C++                                    NUMBER  :  645
  9.   VERSION  :  All
  10.        OS  :  DOS
  11.      DATE  :  September 18, 1991                       PAGE  :  1/2
  12.  
  13.     TITLE  :  Floating Point Formats Not Linked
  14.  
  15.  
  16.  
  17.  
  18.   What is the floating point emulator and when is it used?
  19.  
  20.   The floating  point emulator is used to manipulate floating point
  21.   numbers in runtime library functions like scanf() and atof().
  22.  
  23.   What causes the error?
  24.  
  25.   When  parsing  your  source file, if the  compiler  encounters  a
  26.   reference to the address of a float, it sets a  flag  to have the
  27.   linker link in the floating point emulator.  There are some cases
  28.   in which the  reference  to  the  float  is a bit obscure and the
  29.   compiler does not  detect  the  need  for the emulator.  The most
  30.   common is using scanf()  with  a pointer to a struct containing a
  31.   float.
  32.  
  33.   For example:
  34.  
  35.        struct foo
  36.        {
  37.             float fvar;
  38.        };
  39.  
  40.        void main(void)
  41.        {
  42.             struct foo s1, *s2 = &s1;
  43.             scanf("%f", &s1->fvar);
  44.        }
  45.  
  46.   These situations  usually  occur  during  the  initial  stages of
  47.   program  development.    Normally,  once  the  program  is  fully
  48.   developed, the emulator will  be  used in such a fashion that the
  49.   compiler can accurately determine when to link in the emulator.
  50.  
  51.   How can I force the formats to be linked?
  52.  
  53.   To force linking of the floating point emulator to be linked into
  54.   an application,  just  include  the  following  function  in your
  55.   program:
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  C++                                    NUMBER  :  645
  75.   VERSION  :  All
  76.        OS  :  DOS
  77.      DATE  :  September 18, 1991                       PAGE  :  2/2
  78.  
  79.     TITLE  :  Floating Point Formats Not Linked
  80.  
  81.  
  82.  
  83.  
  84.        void LinkFloat (void)
  85.        {
  86.            float a=0, *b=&a;  /* cause emulator to be linked */
  87.            a=*b;              /* suppress warning var not used */
  88.        }
  89.  
  90.   You do not need  to  call this function, just include it anywhere
  91.   in your program.  Once your project has reached  its  full  size,
  92.   you will most likely be able to remove it from the program.
  93.  
  94.   When will this be changed?
  95.  
  96.   There are no current plans to change the inner  workings  of  the
  97.   compiler  because the intent is to  avoid  linking  the  floating
  98.   point emulator (about 1k of overhead) when it is not required.
  99.  
  100.   Special Cases
  101.  
  102.   An exception to this  rule  occurs with Turbo C version 2.01 when
  103.   using the atof() function.  This is a mistake and  is  fixed in a
  104.   patch file called tc21pt.arc, which is available on CompuServe in
  105.   forum  BPROGB,  LIB  5.  It is also available for download on the
  106.   Borland BBS which can be reached at 408.439.9096.
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.